{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 课程配套的树莓派系统安装说明\n",
    "\n",
    "课程配套树莓派系统安装只需三步。\n",
    "\n",
    "1.下载课程配套的树莓派系统镜像和windows版本的TF卡烧写工具\n",
    "\n",
    "百度云盘地址为:\n",
    "\n",
    "    链接：https://pan.baidu.com/s/14KYZl21Hyf3sjjcWxa5_bg \n",
    "    提取码：dbe5\n",
    "\n",
    "包含系统镜像文件和烧写工具。\n",
    "\n",
    "烧写工具名字为:win32diskimager-1.0.0-install.exe\n",
    "\n",
    "\n",
    "2.安装烧写工具软件，进行镜像烧写\n",
    "\n",
    "在windows下点击“win32diskimager-1.0.0-install.exe”，安装“win32diskimager”软件。\n",
    "\n",
    "安装完毕后，运行“win32diskimager”软件，选择我们要烧写的镜像文件进行烧写。\n",
    "\n",
    "3.启动系统，配置系统\n",
    "\n",
    "将TF卡插入树莓派4B上，连接电源线、显示屏视频线、麦克风线、音箱线、鼠标和键盘线，启动系统。\n",
    "\n",
    "使用raspi-config命令让系统使用所有TF卡容量。\n",
    "\n",
    "将树莓派连接到无线网中。\n",
    "\n",
    "运行桌面上的“开发板外设测试程序”，进行课程开发环境的监测。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "######################################################\n",
    "#\n",
    "# 课程助理——智能小派来讲课,选择本cell，按shirt+enter键运行本模块\n",
    "#\n",
    "######################################################\n",
    "\n",
    "#!/usr/bin/env python\n",
    "# -*- coding: utf-8 -*-\n",
    "#\n",
    "# Copyright (c) 2020 Taste all Pi.\n",
    "#\n",
    "# Licensed under the GNU General Public License, Version 2.0 (the \"License\");\n",
    "# you may not use this file except in compliance with the License.\n",
    "# You may obtain a copy of the License at\n",
    "#\n",
    "#   http://www.gnu.org/licenses/gpl-2.0.html\n",
    "#\n",
    "# Unless required by applicable law or agreed to in writing, software\n",
    "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
    "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
    "# See the License for the specific language governing permissions and\n",
    "# limitations under the License.\n",
    "\n",
    "#导入标准库\n",
    "import sys\n",
    "import os\n",
    "\n",
    "#导入自定义库\n",
    "sys.path.append('../baidu_api_lib')\n",
    "from baidu_sound import baidu_word_2_sound\n",
    "\n",
    "\"\"\" 公开课的语音合成+人脸识别，可选更改为自己的api接口 \"\"\"\n",
    "APP_ID = '20558036'\n",
    "API_KEY = 'u3L19UyWw6Tmx8fvnkqufP4y'\n",
    "SECRET_KEY = '7VjAOyufSVY3IjlM6WV79xrhtivGwO8O'\n",
    "\n",
    "#阅读的内容\n",
    "rd_poem = [\"课程配套的树莓派系统安装说明:\",\\\n",
    "            \"1.下载课程配套的树莓派系统镜像和windows版本的TF卡烧写工具\",\\\n",
    "            \"百度云盘上分享资源，包含系统镜像文件和烧写工具。\",\\\n",
    "            \"2.安装烧写工具软件，进行镜像烧写\",\\\n",
    "            \"在windows下安装“win32diskimager”软件。\",\\\n",
    "            \"安装完毕后，运行“win32diskimager”软件，选择我们要烧写的镜像文件进行烧写。\",\\\n",
    "            \"3.启动系统，配置系统\",\\\n",
    "            \"将TF卡插入树莓派4B上，连接电源线、显示屏视频线、麦克风线、音箱线、鼠标和键盘线，启动系统。\",\\\n",
    "            \"使用raspi-config命令让系统使用所有TF卡容量。\",\\\n",
    "            \"将树莓派连接到无线网中。\",\\\n",
    "            \"运行桌面上的“开发板外设测试程序”，进行课程开发环境的监测。\"]\n",
    " \n",
    "if __name__ == \"__main__\":\n",
    "    try:\n",
    "        #传入百度AI的参数\n",
    "        word_2_sound = baidu_word_2_sound(APP_ID, API_KEY, SECRET_KEY)\n",
    "            \n",
    "        #以迭代方式阅读\n",
    "        for one_poem in rd_poem:\n",
    "            #进行语音合成\n",
    "            word_2_sound.trans_word_to_sound(one_poem,'tst_sound.wav')\n",
    "\n",
    "            #播放合成的语音\n",
    "            os.system('mplayer ' + 'tst_sound.wav')\n",
    "        \n",
    "        #删除临时文件    \n",
    "        os.remove('tst_sound.wav')\n",
    "        \n",
    "    except KeyboardInterrupt:\n",
    "        #删除临时文件    \n",
    "        os.remove('tst_sound.wav')\n",
    "        \n",
    "        print(\"任务被终止了\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
